package com.kmxd.ams.core.exception;

/**
 * description
 *
 * @author nickbi
 */
public abstract class AbstractException extends RuntimeException {

  /** 错误码 */
  protected String code;

  protected String msg;
  protected String methodName;
  protected String className;
  /** 错误信息，过滤后的堆栈信息 */
  protected String debugMessage;

  protected AbstractException(
      final LogInfo recordInfo, final String errorCode, final String debugMessage) {
    this.code = errorCode;
    this.className = recordInfo.getClassName();
    this.methodName = recordInfo.getMethodName();
    this.debugMessage = debugMessage;
  }

  protected AbstractException(final LogInfo recordInfo, final String errorCode) {
    this(recordInfo, errorCode, null);
  }

  public String getCode() {
    return code;
  }

  public void setCode(String code) {
    this.code = code;
  }

  public String getMsg() {
    return msg;
  }

  public void setMsg(String msg) {
    this.msg = msg;
  }

  public String getMethodName() {
    return methodName;
  }

  public void setMethodName(String methodName) {
    this.methodName = methodName;
  }

  public String getClassName() {
    return className;
  }

  public void setClassName(String className) {
    this.className = className;
  }

  public String getDebugMessage() {
    return debugMessage;
  }

  public void setDebugMessage(String debugMessage) {
    this.debugMessage = debugMessage;
  }

  @Override
  public String toString() {
    return "AbstractException{"
        + "code='"
        + code
        + '\''
        + ", msg='"
        + msg
        + '\''
        + ", methodName='"
        + methodName
        + '\''
        + ", className='"
        + className
        + '\''
        + ", debugMessage='"
        + debugMessage
        + '\''
        + "} "
        + super.toString();
  }
}
